$('.item>div').click(function(){
	$(this).addClass('active').siblings().removeClass('active');
	$('.content>div').eq($(this).index()).addClass('show').siblings().removeClass('show');
})
//注册
$('.user_name').blur(function(){
	$.ajax({
		url : 'http://chonghekj.com/todo/index.php/Home/User/checkUserName',
		type: 'post',
		dataType: 'json',
		data: {
			user_name:$('.user_name').val(),
		},
		success: function(res){
			// console.log(res);
			if(res.info == '用户名重复'){
				$('.repit').css('display','block');
			}
		}
	})
})
$('.user_name').focus(function(){
	$('.repit').css('display','none');
})

$('.login_successful').blur(function(){
	$('.login_successful').arrt('display','none');
})

let flag = true;
$('.xian1').click(function(){
	if(flag){
		$('.pw').attr('type','text');
		$('.xian1').attr('src','images/bi.png');
	}else{
		$('.pw').attr('type','password');
		$('.xian1').attr('src','images/kai.png');
	}
	flag = !flag;
})

$('.xian2').click(function(){
	if(flag){
		$('.user_password').attr('type','text');
		$('.xian2').attr('src','images/bi.png');
	}else{
		$('.user_password').attr('type','password');
		$('.xian2').attr('src','images/kai.png');
	}
	flag = !flag;
})
$('.zhu').click(function(){
	$.ajax({
		url : 'http://chonghekj.com/todo/index.php/Home/User/reg',
		type: 'post',
		dataType: 'json',
		data: {
			user_name: $('.user_name').val(),
			user_password: $('.user_password').val(),
			user_email:$('.user_email').val(),
		},
		success: function(res){
			// console.log(res);
			if(res.info == "注册成功"){
				$('.login_successful').css('display','block');
				setTimeout(function(){
					$('.login_successful').css('display','none');
				},3000)
			}else{
				$('.login_dif').css('display','block');
				setTimeout(function(){
					$('.login_dif').css('display','none');
				},1500)
			}
			
		}
	})
})

$('.deng').click(function(){
	$.ajax({
		url: 'http://chonghekj.com/todo/index.php/Home/User/login',
		type: 'post',
		dataType: 'json',
		data: {
			user_name: $('.cell_Num').val(),
			user_password: $('.pw').val(),
		},
		success: function(res){
			console.log(res);
			if(res.info == "登陆成功"){
			}
			$('.cell_Num').val("");
			$('.pw').val("");
			localStorage.setItem('userinfo', JSON.stringify(res.data));
			location.href = `center.html`;
		}
	})
})

